<?php

namespace app\servergoods\traits;

trait GetCateTree
{
	/**
     * @author:      李颖
     * @DateTime:    2017-09-29 11:24:06
     * @Description: 获取某应用下的分类树
     * @Description: 该条分类的必有结构 app_id other_app_read is_public pid
     * @Description: 适用于小型简单分类数据表
     */
	private function _getCateTree(array $data, string $logicPath, string $dbAllCateListMethod = 'dbAllCateList'): array 
    {
        $logic = new $logicPath;
        $list = $logic->$dbAllCateListMethod(['app_id'=>$data['app_id']]);
        $list = mosaic_child($list, false); //添加status_text 字段 用于后台展示
        $list = list_to_tree($list,'id','pid','_child',$data['id']);
        //若$data['id']不为0 则此分类也加进去
        /*if($data['id']){
            $cateInfo = $this->dbCateInfo(['id'=>$data['id']]);
            if($cateInfo){
                $cateInfo['_child'] = $list;
                $res = $cateInfo;
            }else{
                $res = [];
            }
            
        }else{
            $res = $list;
        }
        return auto_return($res);*/
        return auto_return($list);
    }
}